#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2019, Intel Corporation
#
#
# obj_rpmem_basic_integration/TEST12 -- remote replication from and to
# device dax
#

EXE=obj_basic_integration

. ../unittest/unittest.sh

require_test_type medium

require_nodes 2
require_node_dax_device 0 1
require_node_dax_device 1 1
require_node_libfabric 0 $RPMEM_PROVIDER
require_node_libfabric 1 $RPMEM_PROVIDER

setup

init_rpmem_on_node 1 0

# upload test
copy_files_to_node 1 . ../$EXE/$EXE$EXESUFFIX

# define files and directories
TEST_SET_LOCAL="testset_local"
TEST_SET_REMOTE="testset_remote"

# create and upload poolset files
create_poolset $DIR/$TEST_SET_LOCAL AUTO:$(get_node_devdax_path 1 0):x \
	m ${NODE_ADDR[0]}:$TEST_SET_REMOTE
create_poolset $DIR/$TEST_SET_REMOTE AUTO:$(get_node_devdax_path 0 0):x

copy_files_to_node 0 ${NODE_DIR[0]} $DIR/$TEST_SET_REMOTE
copy_files_to_node 1 ${NODE_DIR[1]} $DIR/$TEST_SET_LOCAL

expect_normal_exit run_on_node 1 ../pmempool rm -sf ${NODE_DIR[1]}$TEST_SET_LOCAL
expect_normal_exit run_on_node 0 ../pmempool rm -sf ${NODE_DIR[0]}$TEST_SET_REMOTE

# execute test
expect_normal_exit run_on_node 1 ./$EXE$EXESUFFIX ${NODE_DIR[1]}$TEST_SET_LOCAL

pass
